<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        账号:<input id="account" name="account" /> <br />
        密码:<input id="passwd" name="passwd" /> <br />
        <button id="reg">注册</button>
        <button id="login">登陆</button>
    </div>
</body>
<script src="jquery.js"></script>
<script>
    window.onload = function(){
        //注册
        $("#reg").click(function(){
          let account = $("#account").val();
          let passwd = $("#passwd").val();
          if(!account){
              alert('请输入账号')
              return
          }
          if(!passwd){
              alert('请输入密码')
          }
          $.ajax({
              url:"/reg",
              method:"POST",
              data:{account,passwd},
              success:function(res){
                alert(res)
              },
              error:function(err){
                  console.log(err)
              }
          })
        })
        //登陆
        $("#login").click(function(){
            let account = $("#account").val();
          let passwd = $("#passwd").val();
          if(!account){
              alert('请输入账号')
              return
          }
          if(!passwd){
              alert('请输入密码')
          }
          $.ajax({
              url:"/login",
              method:"POST",
              data:{account,passwd},
              success:function(res){
                alert(res)
              },
              error:function(err){
                  console.log(err)
              }
          })
        })
    }
</script>
</html>